class Solution:
    def countBits(self,n:int):
        bits=[]
        bits.append(0)
        if n==0:
            return bits
        bits.append(1)
        if n==1:
            return  bits
        for i in range(2,n+1):
            if i%2==0:
                bits.append(bits[i//2])
            else:
                bits.append(bits[i//2]+1)
        return bits